package com.design_patterns.demo;

import java.util.ArrayList;
import java.util.List;

public class test {

    public static void main(String[] args) {
        demo2();
    }

    public static void demo2() {
        ExecutorDemo instance = ExecutorDemo.getInstance();
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            instance.doSql(new Thread(() -> {
                for (int j = 0; j < 10; j++) {
                    System.err.println(finalI + "-" + j);
                }
            }));
        }
        instance.shutdown();
    }

    public static void demo1() {
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            new Thread(() -> {
                List<String> sqlList = new ArrayList<>();
                for (int j = 0; j < 10; j++) {
                    sqlList.add(finalI + "-" + j);
                }
                doClass.saveSql(sqlList);
                try {
                    doClass.doSql();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }
    }
}
